﻿//********************************************************************************//
//创建日期：<创建日期，2010-08-02>
//创建作者：<王一飞，wangyifei@shanghai3h.com>
//功能说明：WTB_KEHUXX实体层次
//********************************************************************************//
#region Entity
namespace Entity
{
    using System;
    using System.Xml;
    [Serializable()]
    public class WTB_KEHUXX
    {

        private int m_dec_id;
        /// <summary>
        /// 
        /// </summary>
        public int ID { get { return m_dec_id; } set { m_dec_id = value; } }

        private string m_str_s_zhubiaobh;
        /// <summary>
        /// 
        /// </summary>
        public string S_ZHUBIAOBH { get { return m_str_s_zhubiaobh; } set { m_str_s_zhubiaobh = value; } }

        private string m_str_incident_id;
        /// <summary>
        /// 
        /// </summary>
        public string INCIDENT_ID { get { return m_str_incident_id; } set { m_str_incident_id = value; } }

        private string m_str_social_credit_code;
        /// <summary>
        /// 纳税人识别号
        /// </summary>
        public string SOCIAL_CREDIT_CODE { get { return m_str_social_credit_code; } set { m_str_social_credit_code = value; } }

        private string m_str_send_address;
        /// <summary>
        /// 账单送达地址
        /// </summary>
        public string SEND_ADDRESS { get { return m_str_send_address; } set { m_str_send_address = value; } }

        private string m_str_receiver;
        /// <summary>
        /// 收件人
        /// </summary>
        public string RECEIVER { get { return m_str_receiver; } set { m_str_receiver = value; } }

        private string m_str_yb;
        /// <summary>
        /// 邮编
        /// </summary>
        public string YB { get { return m_str_yb; } set { m_str_yb = value; } }

        private string m_str_s_comment;
        /// <summary>
        /// 备注
        /// </summary>
        public string S_COMMENT { get { return m_str_s_comment; } set { m_str_s_comment = value; } }

        private string m_str_s_beiyong1;
        /// <summary>
        /// 提交渠道
        /// </summary>
        public string S_BEIYONG1 { get { return m_str_s_beiyong1; } set { m_str_s_beiyong1 = value; } }

        private string m_str_s_beiyong2;
        /// <summary>
        /// 
        /// </summary>
        public string S_BEIYONG2 { get { return m_str_s_beiyong2; } set { m_str_s_beiyong2 = value; } }

        private string m_str_s_beiyong3;
        /// <summary>
        /// 
        /// </summary>
        public string S_BEIYONG3 { get { return m_str_s_beiyong3; } set { m_str_s_beiyong3 = value; } }
        public WTB_KEHUXX()
        {
        }
    }
}
#endregion
#region EntityProcess
namespace Access.BLL
{
    using System;
    using System.Data;
    //using System.Data.OracleClient;
    using Entity;
    using System.Configuration;
    using System.Data.Common;
    using Platform.Data;
    using Oracle.DataAccess.Client;
    using Oracle.DataAccess.Types;
    using Oracle.DataAccess;
    public class WTB_KEHUXXProcess
    {
        #region Field
        protected string conn;
        #endregion
        #region Construction
        public WTB_KEHUXXProcess() { conn = Platform.Configuration.ConfigHelper.BusinessConnString; }
        #endregion
        #region public

        /// <summary>
        /// 根据WTB_KEHUXX实体添加或者修改WTB_KEHUXX信息
        /// </summary>
        public bool InsertOrUpdate(WTB_KEHUXX WTB_KEHUXX, OracleTransaction Transaction)
        {
            if (WTB_KEHUXX.ID == 0)
            {
                InsertWTB_KEHUXX(WTB_KEHUXX, Transaction);
            }
            else
            {
                UpdateWTB_KEHUXX(WTB_KEHUXX, Transaction);
            }
            return WTB_KEHUXX.ID == 0 ? false : true;
        }

        /// <summary>
        /// 根据WTB_KEHUXX实体添加或修改WTB_KEHUXX信息
        /// </summary>
        public bool InsertOrUpdate(WTB_KEHUXX WTB_KEHUXX)
        {
            return InsertOrUpdate(WTB_KEHUXX, null);
        }



        /// <summary>
        /// 根据WTB_KEHUXX主键删除WTB_KEHUXX信息
        /// </summary>
        /// <param name="ID"></param>
        public bool DeleteWTB_KEHUXX(int ID, OracleTransaction Transaction)
        {
            string spName = "CS_DelWTB_KEHUXX";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = ID;
            int result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            return result == 0 ? false : true;
        }

        /// <summary>
        /// 根据WTB_KEHUXX主键删除WTB_KEHUXX信息
        /// </summary>
        /// <param name="ID"></param>
        public bool DeleteWTB_KEHUXX(int ID)
        {
            return DeleteWTB_KEHUXX(ID, null);
        }

        /// <summary>
        /// 根据条件删除WTB_KEHUXX信息
        /// </summary>
        /// <param name="WhereClause">条件子句(Oracle语句)不带where</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>如果删除成功，返回true,否则返回fals</returns>
        public bool DeleteWTB_KEHUXXesDynamic(string WhereClause, OracleTransaction Transaction)
        {
            string spName = "CS_DelWTB_KEHUXXesDyn";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = WhereClause;
            int result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            return result == 0 ? false : true;
        }

        /// <summary>
        /// 根据条件删除WTB_KEHUXX信息
        /// </summary>
        /// <param name="WhereClause">条件子句(Oracle语句)不带where</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>如果删除成功，返回true,否则返回fals</returns>
        public bool DeleteWTB_KEHUXXesDynamic(string WhereClause)
        {
            return DeleteWTB_KEHUXXesDynamic(WhereClause, null);
        }

        /// <summary>
        /// 根据WTB_KEHUXX主键选择WTB_KEHUXX信息
        /// </summary>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>WTB_KEHUXX信息</returns>
        public WTB_KEHUXX SelectWTB_KEHUXX(int ID, OracleTransaction Transaction)
        {
            string spName = "CS_SelWTB_KEHUXX";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = ID;
            OracleDataReader rd;
            if (Transaction == null)
                rd = OracleHelper.ExecuteReader(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                rd = OracleHelper.ExecuteReader((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (rd.Read())
            {
                WTB_KEHUXX WTB_KEHUXX = PopulateWTB_KEHUXX(rd);
                rd.Close();
                return WTB_KEHUXX;
            }
            else
                return null;
        }

        /// <summary>
        /// 根据WTB_KEHUXX主键选择WTB_KEHUXX信息
        /// </summary>
        /// <returns>WTB_KEHUXX信息</returns>
        public WTB_KEHUXX SelectWTB_KEHUXX(int ID)
        {
            return SelectWTB_KEHUXX(ID, null);
        }

        /// <summary>
        /// 选择所有WTB_KEHUXX信息
        /// </summary>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>所有WTB_KEHUXX信息</returns>
        public DataTable SelectWTB_KEHUXXesAll(OracleTransaction Transaction)
        {
            string spName = "CS_SelWTB_KEHUXXesAll";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            DataSet ds = null;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (ds != null && ds.Tables.Count > 0)
            {
                AddRowNumber(ds.Tables[0]);
                return ds.Tables[0];
            }
            else
                return null;
        }

        /// <summary>
        /// 选择所有WTB_KEHUXX信息
        /// </summary>
        /// <returns>所有WTB_KEHUXX信息</returns>
        public DataTable SelectWTB_KEHUXXesAll()
        {
            return SelectWTB_KEHUXXesAll(null);
        }

        /// <summary>
        /// 根据条件选择WTB_KEHUXX信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>WTB_KEHUXX信息</returns>
        public DataTable SelectWTB_KEHUXXesDynamic(string WhereClause, string OrderByExpression, OracleTransaction Transaction)
        {
            string spName = "CS_SelWTB_KEHUXXesDyn";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = string.IsNullOrEmpty(WhereClause.Trim()) ? "1=1" : WhereClause;
            storedParams[1].Value = OrderByExpression;
            DataSet ds = null;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (ds != null && ds.Tables.Count > 0)
            {
                AddRowNumber(ds.Tables[0]);
                return ds.Tables[0];
            }
            else
                return null;
        }


        /// <summary>
        /// 根据条件选择WTB_KEHUXX信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <returns>WTB_KEHUXX信息</returns>
        public DataTable SelectWTB_KEHUXXesDynamic(string WhereClause, string OrderByExpression)
        {
            return SelectWTB_KEHUXXesDynamic(WhereClause, OrderByExpression, null);
        }



        /// <summary>
        /// 根据条件选择WTB_KEHUXX信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <param name="PageIndex">页码</param>
        /// <param name="PageSize">页数</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>WTB_KEHUXX信息</returns>
        public DataTable SelectWTB_KEHUXXesDynamic(string WhereClause, string OrderByExpression, int PageIndex, int PageSize, OracleTransaction Transaction)
        {
            string spName = "CS_SelWTB_KEHUXXesDynPaged";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = string.IsNullOrEmpty(WhereClause.Trim()) ? "1=1" : WhereClause;
            storedParams[1].Value = OrderByExpression;
            storedParams[2].Value = PageIndex;
            storedParams[3].Value = PageSize;
            DataSet ds = null;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (ds != null && ds.Tables.Count > 0)
            {
                AddRowNumber(ds.Tables[0]);
                return ds.Tables[0];
            }
            else
                return null;
        }


        /// <summary>
        /// 根据条件选择WTB_KEHUXX信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <param name="PageIndex">页码</param>
        /// <param name="PageSize">页数</param>
        /// <returns>WTB_KEHUXX信息</returns>
        public DataTable SelectWTB_KEHUXXesDynamic(string WhereClause, string OrderByExpression, int PageIndex, int PageSize)
        {
            return SelectWTB_KEHUXXesDynamic(WhereClause, OrderByExpression, PageIndex, PageSize, null);
        }

        /// <summary>
        ///根据条件更新WTB_KEHUXX字段
        /// </summary>
        /// <returns>受影响行数</returns>
        public int UpdateWTB_KEHUXXesDynamic(string UpdateValue, string WhereClause, OracleTransaction Transaction)
        {
            int result = 0;
            if (UpdateValue == "" || WhereClause == "")
            {
                return 0;
            }
            string spName = "CS_UpdWTB_KEHUXXDyn";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            DataSet ds = null;
            storedParams[0].Value = UpdateValue;
            storedParams[1].Value = WhereClause;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            result = Convert.ToInt32(storedParams[2].Value);
            return result;
        }

        /// <summary>
        ///根据条件更新WTB_KEHUXX字段
        /// </summary>
        /// <returns>受影响行数</returns>
        public int UpdateWTB_KEHUXXesDynamic(string UpdateValue, string WhereClause)
        {
            return UpdateWTB_KEHUXXesDynamic(UpdateValue, WhereClause, null);
        }


        #endregion
        #region Private

        private int InsertWTB_KEHUXX(WTB_KEHUXX WTB_KEHUXX, OracleTransaction Transaction)
        {
            string spName = "CS_InsWTB_KEHUXX";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = WTB_KEHUXX.S_ZHUBIAOBH;
            storedParams[1].Value = WTB_KEHUXX.INCIDENT_ID;
            storedParams[2].Value = WTB_KEHUXX.SOCIAL_CREDIT_CODE;
            storedParams[3].Value = WTB_KEHUXX.SEND_ADDRESS;
            storedParams[4].Value = WTB_KEHUXX.RECEIVER;
            storedParams[5].Value = WTB_KEHUXX.YB;
            storedParams[6].Value = WTB_KEHUXX.S_COMMENT;
            storedParams[7].Value = WTB_KEHUXX.S_BEIYONG1;
            storedParams[8].Value = WTB_KEHUXX.S_BEIYONG2;
            storedParams[9].Value = WTB_KEHUXX.S_BEIYONG3;
            int result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            WTB_KEHUXX.ID = Convert.ToInt32(storedParams[10].Value);
            return result;
        }
        private bool UpdateWTB_KEHUXX(WTB_KEHUXX WTB_KEHUXX, OracleTransaction Transaction)
        {
            string spName = "CS_UpdWTB_KEHUXX";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = WTB_KEHUXX.S_ZHUBIAOBH;
            storedParams[1].Value = WTB_KEHUXX.INCIDENT_ID;
            storedParams[2].Value = WTB_KEHUXX.SOCIAL_CREDIT_CODE;
            storedParams[3].Value = WTB_KEHUXX.SEND_ADDRESS;
            storedParams[4].Value = WTB_KEHUXX.RECEIVER;
            storedParams[5].Value = WTB_KEHUXX.YB;
            storedParams[6].Value = WTB_KEHUXX.S_COMMENT;
            storedParams[7].Value = WTB_KEHUXX.S_BEIYONG1;
            storedParams[8].Value = WTB_KEHUXX.S_BEIYONG2;
            storedParams[9].Value = WTB_KEHUXX.S_BEIYONG3;
            storedParams[10].Value = WTB_KEHUXX.ID;
            int result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            return result == 0 ? false : true;
        }


        private WTB_KEHUXX PopulateWTB_KEHUXX(IDataReader dr)
        {
            WTB_KEHUXX WTB_KEHUXX = new WTB_KEHUXX();
            WTB_KEHUXX.ID = Convert.ToInt32(dr["ID"].ToString());
            WTB_KEHUXX.S_ZHUBIAOBH = dr["S_ZHUBIAOBH"] == DBNull.Value ? null : (string)dr["S_ZHUBIAOBH"];
            WTB_KEHUXX.INCIDENT_ID = dr["INCIDENT_ID"] == DBNull.Value ? null : (string)dr["INCIDENT_ID"];
            WTB_KEHUXX.SOCIAL_CREDIT_CODE = dr["SOCIAL_CREDIT_CODE"] == DBNull.Value ? null : (string)dr["SOCIAL_CREDIT_CODE"];
            WTB_KEHUXX.SEND_ADDRESS = dr["SEND_ADDRESS"] == DBNull.Value ? null : (string)dr["SEND_ADDRESS"];
            WTB_KEHUXX.RECEIVER = dr["RECEIVER"] == DBNull.Value ? null : (string)dr["RECEIVER"];
            WTB_KEHUXX.YB = dr["YB"] == DBNull.Value ? null : (string)dr["YB"];
            WTB_KEHUXX.S_COMMENT = dr["S_COMMENT"] == DBNull.Value ? null : (string)dr["S_COMMENT"];
            WTB_KEHUXX.S_BEIYONG1 = dr["S_BEIYONG1"] == DBNull.Value ? null : (string)dr["S_BEIYONG1"];
            WTB_KEHUXX.S_BEIYONG2 = dr["S_BEIYONG2"] == DBNull.Value ? null : (string)dr["S_BEIYONG2"];
            WTB_KEHUXX.S_BEIYONG3 = dr["S_BEIYONG3"] == DBNull.Value ? null : (string)dr["S_BEIYONG3"];
            return WTB_KEHUXX;
        }


        private void AddRowNumber(DataTable dt)
        {
            dt.Columns.Add(new DataColumn("RowNumber", typeof(int)));
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                dt.Rows[i][dt.Columns.Count - 1] = i + 1;
            }
        }
        #endregion
    }
}
#endregion